package com.zoe.wan.android.example.repository.data

import android.os.Parcel
import android.os.Parcelable


/**
 * 首页列表数据实体返回
 */
data class HomeListData(
    val curPage: Int?,
    val datas: List<HomeListItemData>?,
    val offset: Int?,
    val over: Boolean?,
    val pageCount: Int?,
    val size: Int?,
    val total: Int?
)

data class HomeListItemData(
    val adminAdd: Boolean?,
    val apkLink: String?,
    val audit: Int?,
    val author: String?,
    val canEdit: Boolean?,
    val chapterId: Int?,
    val chapterName: String?,
    var collect: Boolean?,
    val courseId: Int?,
    val desc: String?,
    val descMd: String?,
    val envelopePic: String?,
    val fresh: Boolean?,
    val host: String?,
    val id: Int?,
    val isAdminAdd: Boolean?,
    val link: String?,
    val niceDate: String?,
    val niceShareDate: String?,
    val origin: String?,
    val prefix: String?,
    val projectLink: String?,
    val publishTime: Long?,
    val realSuperChapterId: Int?,
    val selfVisible: Int?,
    val shareDate: Long?,
    val shareUser: String?,
    val superChapterId: Int?,
    val superChapterName: String?,
    val tags: List<Any?>?,
    val title: String?,
    val type: Int?,
    val userId: Int?,
    val visible: Int?,
    val zan: Int?
) : Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
        parcel.readString(),
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readString(),
        parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readString(),
        parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
        parcel.readString(),
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readValue(Long::class.java.classLoader) as? Long,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Long::class.java.classLoader) as? Long,
        parcel.readString(),
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readString(),
        parcel.readList(mutableListOf<Any?>(), Any::class.java.classLoader) as List<Any?>?,
        parcel.readString(),
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Int::class.java.classLoader) as? Int,
        parcel.readValue(Int::class.java.classLoader) as? Int
    ) {
    }

    override fun describeContents(): Int {
        return 0
    }

    override fun writeToParcel(p0: Parcel, p1: Int) {
        p0.writeValue(adminAdd)
        p0.writeString(apkLink)
        p0.writeValue(audit)
        p0.writeString(author)
        p0.writeValue(canEdit)
        p0.writeValue(chapterId)
        p0.writeString(chapterName)
        p0.writeValue(collect)
        p0.writeValue(courseId)
        p0.writeString(desc)
        p0.writeString(descMd)
        p0.writeString(envelopePic)
        p0.writeValue(fresh)
        p0.writeString(host)
        p0.writeValue(id)
        p0.writeValue(isAdminAdd)
        p0.writeString(link)
        p0.writeString(niceDate)
        p0.writeString(niceShareDate)
        p0.writeString(origin)
        p0.writeString(prefix)
        p0.writeString(projectLink)
        p0.writeValue(publishTime)
        p0.writeValue(realSuperChapterId)
        p0.writeValue(selfVisible)
        p0.writeValue(shareDate)
        p0.writeString(shareUser)
        p0.writeValue(superChapterId)
        p0.writeString(superChapterName)
        p0.writeList(tags)
        p0.writeString(title)
        p0.writeValue(type)
        p0.writeValue(userId)
        p0.writeValue(visible)
        p0.writeValue(zan)
    }

    companion object CREATOR : Parcelable.Creator<HomeListItemData> {
        override fun createFromParcel(parcel: Parcel): HomeListItemData {
            return HomeListItemData(parcel)
        }

        override fun newArray(size: Int): Array<HomeListItemData?> {
            return arrayOfNulls(size)
        }
    }
}